﻿package edu.pku.se.chocolate.datastructure;

import java.io.Serializable;

/**
 * 
 * @author Jas0n
 *
 */

public class Tag implements Serializable {
	/**
	 * I don't know why I need to do this......
	 */
	private static final long serialVersionUID = 3171199983117227965L;
	//标签ID
	public int ID;
	//标签所属大类
	public String catagory;
	//标签名称
	public String name;
	//源
	public String source;
	//关键字
	public String keyword;
	//标签类型://1 表示预设类，2表示自定义类中非BBS版块部分源，3表示BBS版块
	public int type;
	//更新数
	public int new_msg_num;
	//该标签下本地最新的消息的ID
	public int latest_msg_id;
	//该标签是否及时通知
	public int isNotify;
	
	/**
	 * This is a light-weight construct. It leaves
	 * everything unset.
	 */
	public Tag() {
		
	}
	
	public Tag(int ID, String catagory,String name,String source,String keyword,int type,int new_msg_num,int latest_msg_id,int isNotify){
		this.ID = ID;
		this.catagory = catagory;
		this.name = name;
		this.source = source;
		this.keyword = keyword;
		this.type = type;
		this.new_msg_num = new_msg_num;
		this.latest_msg_id =latest_msg_id ; 
		this.isNotify = isNotify;
	}
	/**
	 * 获取与服务器交互时的标签的标识,格式为:
	 * "type&source&keyword"
	 * @return
	 */
	public String getTagIdentity(){
		if (type == 3){
			int index = source.indexOf('/');		
			return ""+type+"&"+source.substring(0, index)+"&"+keyword;
		}
		else
			return ""+type+"&"+source+"&"+keyword;
	}	
	@Override
	public String toString() {		
		return "{ID:"+ID+","
		+"ctg:"+catagory+","
		+"name:"+name+","
		+"source:"+source+","
		+"keyword:"+keyword+","
		+"type:"+type+","
		+"isnotify:"+isNotify+","
		+"new_msg_num:"+new_msg_num+","
		+"latest_msg_id:"+latest_msg_id+","
		+"}";
	}
}
